<?php
/**
 * Created by 陈俊伟.
 * User: Administrator
 * Date: 2019-11-13
 * Time: 下午 6:59
 */

namespace App\Lib\Zhuzhuyun;
/*
 * 猪猪云物流查询封装
 * */
class Zhuzhuyun
{
    private $appid = 105112;
    private $outerid = 'CtwQswskg0D4FaSO';
    private $zffs = 'jinbi';
    private $task_url = 'http://yun.zhuzhufanli.com/mini/create/';
    private $query_url = 'http://yun.zhuzhufanli.com/mini/select/';
    /*
     * 创建物流查询任务
     * @ $kdgs 快递公司拼音
     * @ $kddhs 该快递公司下的所有物流单号 用逗号隔开
     * */
    public function createTask($kdgs,$kddhs)
    {
        $param = [
            'appid' => $this->appid,
            'outerid' => $this->outerid,
            'zffs' => $this->zffs,
            'kdgs' => $kdgs,
            'kddhs' => $kddhs,
            'isBackTaskName' => 'yes'
        ];
        $result = curlPost($this->task_url,$param);
        if(!is_array($result)){
            $result = json_decode($result,true);
        }
        return $result;
    }

    /*
   * 创建物流查询任务
   * @ $kdgs 快递公司拼音
   * @ $kddhs 该快递公司下的所有物流单号 用逗号隔开
   * */
    public function queryTask($pageno,$taskname)
    {
        $param = [
            'appid' => $this->appid,
            'outerid' => $this->outerid,
            'pageno' => $pageno,
            'taskname' => $taskname
        ];
        $result = curlPost($this->query_url,$param);

        if(!is_array($result)){
            $result = json_decode($result,true);
        }
        return $result;
    }
}